const MyPromise = require("./myPromise")

let promise = new MyPromise((resolve, reject) => {
    // setTimeout(()=>{
    //     resolve('成功')
    // },2000)
    // throw new Error("执行器错误")
    // resolve("成功")
    reject('失败111')
})

promise.catch(reason=>{
    console.log(reason+"---")
})

// promise.finally(()=>{
//     console.log(123)
//     return p1()
// }).then(value=>{
//     console.log(value)
// },reason=>{
//     console.log(reason+"88888888")
// })

// promise.then().then(value=>console.log(value),reason=>console.log(123))

// promise.then((value) => {
//     console.log(value)
// }, (reason) => {
//     console.log(reason)
// }
// )


function p1() {
    return new MyPromise(function (resolve, reject) {
        setTimeout(() => {
            resolve("p1")
        }, 3000)
    })
}

function p2() {
    return new MyPromise(function (resolve, reject) {
        resolve("p2")
    })
}


// MyPromise.all(['a', 'b', p1(), p2(), 'e']).then((value) => {
//     console.log(value)
// })

// let p3 = MyPromise.resolve(123)
// p3.then(value=>console.log(value))





